import Reflux from 'reflux';
import PageConst from './PageConst';
import Actions from './Actions';
import update from 'react-addons-update';
import nattyStorage from 'natty-storage';
import DB from '../../../app/db';

export default Reflux.createStore({
  listenables: [Actions],
  data: {
    ...PageConst,
    projectHeader:{},
    cxzjjiafenData:[
      {
        xingweimiaoshu:"在施工中使用未经检测或检测不合格的结构用建筑材料、建筑构配件",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"分部分项工程未组织质量验收，扇子进入下道工序施工的",
        fenzhi:"-5.0",
        time:"2017-7-7",
        youxiaoyue:"6"
      },
      {
        xingweimiaoshu:"危险性较大的分部分项工程未编制专项施工方案",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"使用未经验收或者验收不合格的施工起重机械和整体提升脚手架、模板等自升式架设设施",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"未满足分户验收相关要求的；或不履行保修义务或拖延履行保修义务",
        fenzhi:"-5.0",
        time:"2017-7-7",
        youxiaoyue:"6"
      },
      {
        xingweimiaoshu:"在尚未竣工的建筑物内设置员工集体宿舍",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"使用不符合施工图设计文件要求的墙体材料、保温材料和门窗",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      }
    ],
    cxzjjianfenData:[
      {
        xingweimiaoshu:"在施工中使用未经检测或检测不合格的结构用建筑材料、建筑构配件",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"分部分项工程未组织质量验收，扇子进入下道工序施工的",
        fenzhi:"-5.0",
        time:"2017-7-7",
        youxiaoyue:"6"
      },
      {
        xingweimiaoshu:"危险性较大的分部分项工程未编制专项施工方案",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"使用未经验收或者验收不合格的施工起重机械和整体提升脚手架、模板等自升式架设设施",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"未满足分户验收相关要求的；或不履行保修义务或拖延履行保修义务",
        fenzhi:"-5.0",
        time:"2017-7-7",
        youxiaoyue:"6"
      },
      {
        xingweimiaoshu:"在尚未竣工的建筑物内设置员工集体宿舍",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      },
      {
        xingweimiaoshu:"使用不符合施工图设计文件要求的墙体材料、保温材料和门窗",
        fenzhi:"-10.0",
        time:"2017-7-7",
        youxiaoyue:"12"
      }
    ]
  },

  onSetHeader:function (detail) {
    this.data.projectHeader=update(this.data.projectHeader,{$set:detail});
    this.updateComponent();
  },

  onFetch: function (params, cb) {
    let t = this;
    t.updateComponent();
    cb && cb(t.data);
  },

  updateComponent: function () {
    this.trigger(this.data);
  },

  getInitialState: function () {
    return this.data;
  }
});
